#ifndef PREQ_H_
#define PREQ_H_

#include <assert.h>
#include <iostream>

#include "uarch/mreq.h"
#include "uarch/stat.h"
#include "uarch/types.h"

using namespace std;

class Preq_entry {
public:
    timestamp_t time;
    Mreq *request;
    char *msg;
};

class Preq {
public:

    ModuleID mid;
    Processor_context *context;
    message_t msg;
    paddr_t pc;
	paddr_t addr;
    timestamp_t req_time;
    timestamp_t resolve_time;
    bool resolved;

    int req_count;

    LIST <Preq_entry> history;
    timestamp_t request_latencies[INVALID_M];

    void add_to_history (Mreq* request, const char *msg = NULL);
    void calculate_latencies (timestamp_t complete);

    Preq ();
    Preq (ModuleID id, Processor_context *context, paddr_t pc, paddr_t addr, message_t msg);
	~Preq ();

	void dump ();
    void print_history (void);
};

#endif /*PREQ_H_*/
